package com.kinyx.framework.constraints;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import javax.validation.Constraint;
import javax.validation.Payload;

import com.kinyx.framework.constraints.Validator._Validator;

/**
 * 验证验证注解
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = _Validator.class)
public @interface Validator {

	String message() default "";

	Class<?>[] groups() default {};

	Class<? extends Payload>[] payload() default {};

	String regex();

	class _Validator extends RegexMatchValidator<Validator> {

		private String regex;

		@Override
		public void initialize(final Validator annotation) { this.regex = annotation.regex(); }

		@Override
		protected String getRegex() { return this.regex; }

	}

}
